(function() {
    angular.module('app').component('timePickerComponent', {
        templateUrl: 'app/components/time.picker.component/time.picker.component.html',
        controller: timePickerComponent,
        controllerAs: 'vm',
        bindings:{
            dropdownMenu:'='
        }
    });

    timePickerComponent.$inject = ['$rootScope'];

    function timePickerComponent($rootScope) {
        var vm = this;

        vm.$onInit = function(){



        };

        // dropdown
        vm.dropdown = {
            cur: {
                text: '昨天',
                value: 'yestory'
            },
            onSelect: function(item, _index) {

                if (angular.equals(this.cur, item)) {
                    return;
                }

                this.cur = item;

                $rootScope.$emit('timer-picker-component-EV', this.cur);

            },
            list: [{
                text: '昨天',
                value: 'yestory'
            }, {
                text: '前天',
                value: 'yestory'
            }, {
                text: '近7天',
                value: 'week'
            }, {
                text: '近一个月',
                value: 'month'
            }]
        };

        // 自定义时间
        vm.custom = {
            lowImportTime: '',
            highImportTime: '',
            emit: function() {
                console.log("low:" + this.lowImportTime + " high:" + this.highImportTime);
            }
        };

        vm.showCustomTimer = false;
        vm.showCustom = function() {
            console.log(vm.showCustomTimer);
            vm.showCustomTimer = !vm.showCustomTimer;          
        };
    }

})();
